Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"ODE" quantities and user defined external sources #427

Merged
merged 49 commits into from
Oct 22, 2024

Conversation

dmontgomeryNREL
Copy link
Contributor

@dmontgomeryNREL dmontgomeryNREL commented Oct 15, 2024

This PR introduces a quantity that varies in time, but is neither advected or diffused. I'll refer to it as an ode_qty for now. In PeleC these would be AUX quantities, but there already exists a placeholder for AUX in PeleLMeX that is not a state variable. I intend to rename the existing aux quantities to ADV and these ode quantities to AUX for consistency with PeleC, but that will be a large PR in itself.

The ode quantities are included in the state variable and satisfy $\frac{\partial B_k}{\partial t} = S_{ext,B_k}$, for $k = 0, 1,...,$NUM_ODE. Currently this is only first order accurate in time, but is consistent with the treatment of external sources from soot, spray and radiation, which are calculated prior to the SDC iterations. In the future I would like to add the ability to update the source terms within the SDC iterations, but this may require solving additional nonlinear systems depending on the source terms. For now we assume that the source terms are constant from $t^{n} \rightarrow t^{n+1}$.

In addition to the ode quantities, this PR includes PeleLMeX_ProblemSpecificFunctions.cpp which allows users to define the name of the ode quantities as well as external source terms for any state variable. Note that external source terms for density, $S_{ext,\rho}$, affect the velocity constraint but this has not been addressed in this PR. For reference, the velocity constraint should be:
$\nabla \cdot \vec{u} = \frac{1}{T}\frac{DT}{Dt} + W \displaystyle\sum_m \frac{1}{W_m} \frac{DY_m}{Dt} + \frac{1}{\rho} S_{\text{ext},\rho} = S.$
Note that the existing external force terms for soot, spray and radiation are now included in the function called getExternalSources in PeleLMeX_Forces.cpp.

I tested 3 ode quantities of increasing stiffness with $S_{ext} = -10^{k+2} \cdot B_k$, for $k = 0,1,2$. The results below demonstrate first order accuracy and the need for SDC iterations in the future.

ODEQty

solutions

convergence_SDC-0_stiff

…tiple ode vars. Still working on source terms.
Copy link
Collaborator

@baperry2 baperry2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I'm able to run the test case and get the expected results. Just a couple minor changes requested.

One slightly larger thing is to have this run in the CI. You'll need to add it in Tests/CMakeLists.txt and you'll probably also need to add something to define NUM_ODE with the CMake build system similar to NUM_AUX in PeleC: https://github.com/AMReX-Combustion/PeleC/blob/b9ebe80bd3b00db0f50710048e50bac01212ef2b/CMake/BuildPeleExe.cmake#L25

And a clarification is that these quantities aren't spatially invariant, but don't advect or diffuse, so spatial terms don't come up in their governing equations.

Docs/sphinx/manual/Model.rst Show resolved Hide resolved
Source/PeleLMeX_Plot.cpp Outdated Show resolved Hide resolved
Source/PeleLMeX_Plot.cpp Outdated Show resolved Hide resolved
@dmontgomeryNREL dmontgomeryNREL changed the title Spatially invariant quantities and user defined external sources "ODE" quantities and user defined external sources Oct 16, 2024
Tests/CMakeLists.txt Outdated Show resolved Hide resolved
Comment on lines +36 to +56
/*
Notes:
1) ext_src contains sources from velocity forcing coming in.
This function should add to rather than overwrite ext_src.
2) Requires peleLM.user_defined_ext_sources = true in input file

// Example: Exponential decay ode quantity
auto ext_src_arr = ext_src->arrays();
auto const& state_old_arr = state_old.const_arrays();

ParallelFor(
*ext_src,
[=] AMREX_GPU_DEVICE(int box_no, int i, int j, int k) noexcept {
for (int n = 0; n < NUM_ODE; n++) {
Real B_n = state_old_arr[box_no](i, j, k, FIRSTODE + n);
Real src = -1.0 * pow(10.0, n + 1) * B_n;
ext_src_arr[box_no](i, j, k, FIRSTODE + n) += src;
}
});
Gpu::streamSynchronize();
*/

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
@baperry2 baperry2 enabled auto-merge (squash) October 22, 2024 20:31
@baperry2 baperry2 merged commit 0847633 into AMReX-Combustion:development Oct 22, 2024
25 checks passed
@dmontgomeryNREL dmontgomeryNREL deleted the odeQty branch October 23, 2024 03:51
terencelehmann pushed a commit to ITV-RWTH/PeleLMeX that referenced this pull request Nov 14, 2024
* DivU constraint with arbitrary sources (AMReX-Combustion#428)

* Included additional terms in divu constraint to account for external forces on density.

* Updated Docs to include external source terms in model equations and divergence constraint.

* Formatting

* fix a bug in divu calc

* Update deriviation of divu in Docs

* Restored code to development

* Reverted text in line 168

* Minor fix in Docs

* Comment in divu about extRho

---------

Co-authored-by: Bruce Perry <[email protected]>

* "ODE" quantities and user defined external sources (AMReX-Combustion#427)

* Initial commit.  Needs debugging for source terms.

* Added ode_var to typical values. Still debugging initialization and source.

* Minor edit in set_ode_names function.

* Fixed misalignment in plotting. IC's appear to be correct now for multiple ode vars.  Still working on source terms.

* Fix indexing.

* Updated problem_modify_ext_sources.  Works with local case definition.

* Comment arguments in problem_modify_ext_sources in Source code.

* Added compilation variable USE_MODIFIED_SOURCES to avoid unnecessary loops through levels.

* Tested plotting for Efield and Spray.  Tested all args of ProblemSpecificFunctions.

* Added ode_srcstrength to test case, fixed minor bugs.

* Changed flag for user defined external sources.  Added future flag for including external sources in SDC loop.

* Set peleLM.user_defined_ext_sources to true in input file.

* Added Euler step for advancing the ODE quantities in time.

* Changed name of advanceODEQty() to predictODEQty() for consistency with SDC iterations.

* Updated input.2d for validation

* Added .cpp file for ProblemSpecificFunctions to avoid need for static functions.

* Added convergence test for ODE Qty.

* Updated the test case to include 3 odes with increasing stiffness.

* Renamed case

* Combined all external forces in single function call to clean up PeleLMeX_Advance.cpp

* Update README for case.

* Update README for case.

* Update README.md

* Removed NUM_AUX for now.

* Cleaning up

* Documentation for ode quantities.

* Clang-format

* Remove validation tests from case directory.

* Minor fix for soot and spray

* Spelling and unused variable handling.

* Unused variable handling

* Formatting

* Removed unwanted print statements, renamed some files/vars for consistency.

* Added case to CI

* Add USE_EB to EB_ODEQty/CmakeLists.txt

* Add EB_ODEQty to RegTests/CMakeLists.txt

* CI fix

* More CI

* Add ODEQty.cpp to cmake

* More CI...

* Only define predictODEQty if NUM_ODE > 0

* Updated CMake to handle user defined EB's and ProblemSpecificFunctions

* Now passes in MultiFabs for state_old and state_new. This provides access to state_old.Factory() etc.

* Update PeleLMeX_ProblemSpecificFunctions.cpp

* Removed lev argument in problem_modify_ext_sources

* Update comment

---------

Co-authored-by: Bruce Perry <[email protected]>

* pin intel-oneapi version in CI (AMReX-Combustion#434)

* Bump Submodules/AMReX-Hydro from `3ab9864` to `3788361` (AMReX-Combustion#433)

Bumps [Submodules/AMReX-Hydro](https://github.com/AMReX-Fluids/AMReX-Hydro) from `3ab9864` to `3788361`.
- [Commits](AMReX-Fluids/AMReX-Hydro@3ab9864...3788361)

---
updated-dependencies:
- dependency-name: Submodules/AMReX-Hydro
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Bruce Perry <[email protected]>

* Add full manifold model capability (AMReX-Combustion#415)

* basics of having eos_parm in PeleLMeX

* add eosparm to PeleLMeX_K functions

* more eosparm: now everywhere except Efield & BCs

* eosparm in BC stuff

* re-order functions for template

* remove manifold-specfic changes, will go in later PR

* gnu make changes for manifold

* create manifold version of adjust fluxes function

* Add abort for Closed Chamber + Manifold

* Better setup chackes for Manifold + wbar, closed chamber, mixfrac/prog

* advection of rho corrections for manifold models

* manifold-specific transport, derives, divu

* remove divide by zero

* go to templated EOS functions to use cellData

* fix oops in pelephysics

* fix compile errors for Manifold derives

* fix compile condition for transparm initialization

* fix missing RY2RRinvY conversion

* use PelePhysics that free manfunc shared pointer

* clang-formatting

* fux derives for manifold

* add flamesheet test case for manifold

* remove extraneous changes in file

* Update Source/PeleLMeX_Setup.cpp

Co-authored-by: Marc T. Henry de Frahan <[email protected]>

* address Marc HdF's comments with minor formatting

* remove copied line

* update PP for merged RY2R stuff

---------

Co-authored-by: Marc T. Henry de Frahan <[email protected]>

* Update PelePhysics and add path to new utility  (AMReX-Combustion#435)

* Update PelePhysics and add new utility to Make.PeleLMeX

* Add PelePhysics utilities to CMake

* Test PelePhysics:tidy against clang-tidy.

* Update PelePhysics submodule

* Bump Submodules/AMReX-Hydro from `3ab9864` to `3788361` (AMReX-Combustion#438)

Bumps [Submodules/AMReX-Hydro](https://github.com/AMReX-Fluids/AMReX-Hydro) from `3ab9864` to `3788361`.
- [Commits](AMReX-Fluids/AMReX-Hydro@3ab9864...3788361)

---
updated-dependencies:
- dependency-name: Submodules/AMReX-Hydro
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump Submodules/PelePhysics from `327aadb` to `f54b084` (AMReX-Combustion#439)

Bumps [Submodules/PelePhysics](https://github.com/AMReX-Combustion/PelePhysics) from `327aadb` to `f54b084`.
- [Release notes](https://github.com/AMReX-Combustion/PelePhysics/releases)
- [Commits](AMReX-Combustion/PelePhysics@327aadb...f54b084)

---
updated-dependencies:
- dependency-name: Submodules/PelePhysics
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Dave Montgomery <[email protected]>
Co-authored-by: Bruce Perry <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Marc T. Henry de Frahan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants